home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_204 / popinfo / yesno.c < prev   
C/C++ Source or Header  |  1992-05-06  |  2KB  |  53 lines

  1. #include <intuition/intuitionbase.h>
  2.  
  3. #define OKAY 1
  4. #define CANCEL 0
  5.  
  6. short YesNoXYBorder[]={
  7.     0,0,101,0,101,12,0,12,0,0};
  8. struct Border YesNoBorder={
  9.     -1,-1,1,0,JAM1,5,YesNoXYBorder,NULL};
  10. struct IntuiText OkayText={
  11.     1,1,JAM1,5,2,NULL,"    OKAY",NULL};
  12. struct IntuiText CancelText={
  13.     1,1,JAM1,5,2,NULL,"   CANCEL",NULL};
  14. struct Gadget OkayGadget={
  15.     NULL,8,20,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
  16.     (APTR)&YesNoBorder,NULL,&OkayText,NULL,NULL,OKAY,NULL};
  17. struct Gadget CancelGadget={
  18.     &OkayGadget,120,20,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
  19.     (APTR)&YesNoBorder,NULL,&CancelText,NULL,NULL,CANCEL,NULL};
  20.  
  21. struct IntuiText YesNoText={
  22.     1,1,JAM1,8,7,NULL,NULL,NULL};
  23.  
  24. struct NewWindow YesNoWindow={
  25.     50,30,230,36,0,3,GADGETUP|VANILLAKEY,ACTIVATE|RMBTRAP,&CancelGadget,
  26.     NULL,NULL,NULL,NULL,0,0,0,0,CUSTOMSCREEN};
  27.  
  28. struct Window *QWindow;
  29. struct IntuiMessage *MyMsg;
  30. struct IntuitionBase *IntuitionBase;
  31.  
  32. YesNo(text)
  33. char *text;
  34. {
  35.     int Class,Code;
  36.     char key;
  37.     IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0);
  38.     YesNoWindow.Screen=(struct Screen *) IntuitionBase->ActiveScreen;
  39.     QWindow=(struct Window *) OpenWindow(&YesNoWindow);
  40.     YesNoText.IText=text;
  41.     PrintIText(QWindow->RPort,&YesNoText,0,0);
  42.     waitforinput:
  43.     Wait (1<<QWindow->UserPort->mp_SigBit);
  44.     MyMsg=GetMsg(QWindow->UserPort);
  45.     ReplyMsg(MyMsg);
  46.     Class=MyMsg->Class; Code=MyMsg->Code; key=toupper((char ) Code);
  47.     if (Class==VANILLAKEY && key!='Y' && key!='N') goto waitforinput;
  48.     CloseWindow(QWindow);
  49.     CloseLibrary(IntuitionBase);
  50.     if (((struct Gadget *) MyMsg->IAddress)->GadgetID==OKAY || key=='Y') return(TRUE);
  51.     return(FALSE);
  52. }
  53.